package com.ruoyi.creditlife.service.util;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.CreditUserInfo;
import com.ruoyi.system.mapper.CreditUserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserCreditScoreLevel {
    @Autowired
    private CreditUserInfoMapper creditUserInfoMapper;

    public int getReserveBookLevelDays() {
        CreditUserInfo userInfo = creditUserInfoMapper.selectCreditUserInfoByUserId(SecurityUtils.getUserId());
        if (userInfo == null) {
            return 0; // 默认值，可根据实际需求调整
        }

        Integer userScore = userInfo.getCreditScore();
        if (userScore > 600) {
            return 30;
        } else if (userScore > 500) {
            return 15;
        } else if (userScore > 400) {
            return 5;
        } else {
            return 0;
        }
    }
}